	OUTPUT "megarom.rom"
bank0  equ 0x5000
bank1  equ 0x7000
bank2  equ 0x9000
bank3  equ 0xb000

RSLREG	equ	0x0138
EXPTBL	equ	0xFCC1
ENASLT	equ	0x0024

	macro setpage slot
		ld a,slot
		ld (megarom.bank3),a
	endmacro

        defpage 0, 0x4000, 0x2000
        defpage 1, 0x6000, 0x2000
        defpage 2, 0x8000, 0x2000
        defpage 3..63, 0xa000, 0x2000
       

        page 0..2
        map 0xc000

        db "AB"
        dw init
        db 0,0,0,0,0,0

init:   call RSLREG
        rrca
        rrca
        and 0x03
        ld c,a
        ld b,0
        ld hl,EXPTBL
        add hl,bc
        or (hl)
        ld b,a
        inc hl
        inc hl
        inc hl
        inc hl
        ld a,(hl)
        and 0x0c
        or b
        ld h,0x80
        call ENASLT

        ;; default slots
        xor a
        ld (bank0),a
        inc a
        ld (bank1),a
        inc a
        ld (bank2),a
        inc a
        ld (bank3),a
        jp start
        
start:
		
		
	xor		a
	call	0x005F			;screen 0

	call	0x00C3			;cls

	ld		hl,position
	ld		[hl],0

	ld		hl,text3
	ld		de,[position]
	ld		bc,14
	call	0x005c
	
	call	0x009f			;wait keystroke		
		
	ld	a,4
	ld (bank3),a			;bank switch
		


	ld		a,20
	ld		hl,position
	add		[hl]
	ld		[hl],a

	ld		hl,text4
	ld		de,[position]
	ld		bc,14
	call	0x005c
	
	call	0x009f			;wait keystroke		
		
	ld	a,5
	ld (bank3),a			;bank switch




	ld		a,20
	ld		hl,position
	add		[hl]
	ld		[hl],a


	ld		hl,text5
	ld		de,[position]
	ld		bc,14
	call	0x005c
	
		
	
		
		
		
	jr	$
		
	page 3
text3:	
	db "This is page 3",0
	page 4
text4:	
	db "This is page 4",0
	page 5
text5:	
	db "This is page 5",0
	page 6
text6:	
	db "This is page 6",0
	page 7
text7:	
	db "This is page 7",0


	org	0xc000
position:
	ds	666
	

